<template>
  <div class="container">
    <LabelBar v-if="form" label="详情信息" class="item">
      <van-field v-bind="textProps" label="制定日期" :value="form.planDate" readonly />
      <van-field v-bind="textProps" label="出发日期" :value="form.leaveDate" readonly />
      <van-field v-bind="textProps" label="行程信息" :value="form.travel|travelFilter" readonly />
      <van-field v-bind="textProps" label="工具仪器" :value="form.tools" readonly />
      <van-field v-bind="textProps" label="物料清单" :value="form.materielDetail" readonly />
      <van-field v-bind="textProps" label="安全措施" :value="form.safeMeasure" readonly />
      <van-field v-bind="textProps" label="处理方案" :value="form.dealScheme" readonly />
      <van-field v-bind="textProps" label="创建人员" :value="form.createUser" readonly />
      <van-field v-bind="textProps" label="创建日期" :value="form.createTime" readonly />
    </LabelBar>
    <div v-else class="nodata">
      <img src="@/assets/image/nodata.png" alt="">
    </div>

    <div v-if="closedCase" class="btn" @click="jump">
      <img v-if="form" src="@/assets/image/edit.png" alt="">
      <img v-else src="@/assets/image/add.png" alt="">
    </div>

  </div>
</template>

<script>
import LabelBar from '../../components/LabelBar'
import { openWx, urlParams, textProps } from '@/assets/utils'

export default {
  components: { LabelBar },
  filters: {
    travelFilter(key) {
      const map = { '01': '公司派车', '02': '非公司派车' }
      return map[key] || ''
    },
  },
  props: {
    orderInfo: { type: Object, default: null },
  },
  data() {
    return {
      textProps,
      saleServiceId: urlParams.get('saleServiceId'),
      serviceNo: urlParams.get('serviceNo'),

      form: null,
    }
  },
  computed: {
    // 是否已结案
    closedCase() {
      return this.orderInfo?.orderStatus !== '03'
    },
  },
  watch: {},
  created() {
    this.init()
  },
  mounted() {
  },
  methods: {
    init() {
      this.getDetail()
    },

    async getDetail() {
      const res = await this.server.get('/saleService/findSaleServicePlanBySaleServiceId', {
        saleServiceId: this.saleServiceId,
      })
      if (res.code === '0') this.form = res.object
    },

    jump() {
      openWx(`${location.origin}/servicePlan.html`, `&planNo=${this.form?.planNo}`)
    },

  },
}
</script>

<style lang="less" scoped>
.container {
  .btn{
    position: fixed;
    right: 30px;
    bottom: 80px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    img{
      width: 100%;
      height: 100%;
    }
  }
}
</style>
